import { Tag } from 'antd';
import React from 'react';
import { PROMOTION_TYPE, USER_CLASS, USER_STATUS } from '../constants';

export const getPromotionTag = (promotionStatus?: number): React.ReactNode => {
  if (!promotionStatus || promotionStatus === PROMOTION_TYPE.NONE) return null;

  switch (promotionStatus) {
    case PROMOTION_TYPE.FREE:
      return <Tag color="red">免费</Tag>;
    case PROMOTION_TYPE.DOUBLE_UPLOAD:
      return <Tag color="orange">2X上传</Tag>;
    case PROMOTION_TYPE.HALF_DOWNLOAD:
      return <Tag color="green">50%下载</Tag>;
    case PROMOTION_TYPE.DOUBLE_DOWNLOAD:
      return <Tag color="blue">2X下载</Tag>;
    default:
      return null;
  }
};

export const getUserClassTag = (userClass: number): React.ReactNode => {
  const getClassInfo = () => {
    switch (userClass) {
      case USER_CLASS.UNVERIFIED:
        return { text: '未验证', color: 'default' };
      case USER_CLASS.USER:
        return { text: '普通用户', color: 'blue' };
      case USER_CLASS.VIP:
        return { text: 'VIP用户', color: 'green' };
      case USER_CLASS.SENIOR:
        return { text: '资深用户', color: 'geekblue' };
      case USER_CLASS.MODERATOR:
        return { text: '审核员', color: 'purple' };
      case USER_CLASS.ADMIN:
        return { text: '管理员', color: 'gold' };
      case USER_CLASS.SUPER_ADMIN:
        return { text: '超级管理员', color: 'red' };
      default:
        return { text: '未知', color: 'default' };
    }
  };

  const { text, color } = getClassInfo();
  return <Tag color={color}>{text}</Tag>;
};

export const getUserStatusTag = (status: number): React.ReactNode => {
  switch (status) {
    case USER_STATUS.DISABLED:
      return <Tag color="red">已禁用</Tag>;
    case USER_STATUS.ACTIVE:
      return <Tag color="green">正常</Tag>;
    case USER_STATUS.BANNED:
      return <Tag color="volcano">已封禁</Tag>;
    default:
      return <Tag color="default">未知</Tag>;
  }
};